<?php include "coresection/connection.php";?>
<?php include "coresection/checkUserSession.php";?>
<?php include "coresection/search.php"?>
<?php include "coresection/order-list.php";?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <?php include 'modules/head.php'; ?>
</head>

<body>
<?php include 'modules/topbar.php'; ?>


<div class="setup_area">


    <?php include 'modules/sidebar.php'; ?>

    <div class="header">
        <h1>个人订餐汇总</h1>
            <?php include 'modules/header.php'; ?>
    </div>

    <div class="content_area">

        <div class="order_log_box">


<div class="content">
<ol>
    <li>1.当天订单、当天前的订单不能退订！</li>
    <li>2.当天订单超过17:00,不能退订明天订单！</li>
</ol>
</div>



<?
//获取当前查询的日期

if($_REQUEST['month'])
{
    $now_check_month=$_REQUEST['month'];
}
else
{
    $now_check_month=date('m');
}

if($_REQUEST['year'])
{
    $now_check_year=$_REQUEST['year'];
}
else
{
    $now_check_year=date('Y');
}



?>

            <form id="order_log_Form" action="" method="post" autocomplete="off" enctype="multipart/form-data">
            需要查询的就餐月份：
            <select name="year">
			<!--这个可以退订今年，退订旧年。但是当今年12月31日的时候，已经订了明年的，那么明年的就没办法退订了。-->
			<!--所以做个判断，是12月31号的，就要展示明年。-->

                <option value="<? echo $now_check_year ?>"><?echo   $now_check_year ?></option>

			<?if( (date("m",time())==12) && (date("d",time())>29) ) {?>

			<option value="<?echo date("Y",time())+1?>"><?echo date("Y",time())+1 ?></option>
             
            <? ;} ?>		
			
			<option value="<?echo date("Y",time())?>"><?echo date("Y",time())?></option>
                <option value="<?echo date("Y",time())-1?>"><?echo date("Y",time())-1?></option>
            </select>
            年
            <select name="month">

                <option value="<? echo $now_check_month ?>" class="month_1"> <? echo $now_check_month ?>月</option>

                <option value="01" class="month_1">01月</option>
                <option value="02" class="month_2">02月</option>
                <option value="03" class="month_3">03月</option>
                <option value="04" class="month_4">04月</option>
                <option value="05" class="month_5">05月</option>
                <option value="06" class="month_6">06月</option>
                <option value="07" class="month_7">07月</option>
                <option value="08" class="month_8">08月</option>
                <option value="09" class="month_9">09月</option>
                <option value="10" class="month_10">10月</option>
                <option value="11" class="month_11">11月</option>
                <option value="12" class="month_12">12月</option>
            </select>
            <input type="submit" value="查看"/>
        </form>
		
        


       
		<div style="margin-top:25px;margin-bottom:15px;color: red";><? echo $summary_year?> 年 <? echo $summary_month ?> 月 个人订餐汇总</div>
		
        <table cellspacing="0" cellpadding="0" border="0" class="layui-table " id="summary_table">

            <colgroup>
                <col >
                <col >
                <col >
                <col >
                <col>
            </colgroup>

            <thead>
            <tr>
            <td>
                <input type="checkbox" onclick="checkAll(this)" lay-skin="primary" />
                <button class="fulltuidingBtn" ><strong>批量退订</strong></button>
            </td>
                <th>用餐日期</th>
                <th>早/午/晚餐</th>
                <th>就餐人数</th>
                <th>总金额</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <?php for($i=0;$i<$sum;$i++){?>
            <tr>
            

 <td style="text-align: center">
           <? 
		   //以下两处地方，都会用到这个函数，用来控制显示退订
		   
	//得到系统的年月  
    $tmp_date=date("Ym");  
    //切割出月份  
    $tmp_mon =substr($tmp_date,4,2);
	
	
	$order_time=substr($search_date[$i],0,4)."-".substr($search_date[$i],7,2)."-".substr($search_date[$i],12,2);
    strtotime($order_time);
	
	$nowtime = date('Y-m-d');//生成带格式的日期
    strtotime($nowtime);
	
	
	
 if (($summary_month<$tmp_mon)||($order_time<=$nowtime))

	{
        echo "超时,不可退订";
    }
	else{
	?>	

        <input type="checkbox" name="mycheckbox" value="<? echo $search_nid[$i] ?>@<?echo $search_product_id[$i]?>@<?echo $search_price[$i]?>@<?echo $search_date[$i]?>" style=" width:20px; height:20px"  />
                
               
                
          <?  
		  ;} 
		  ?>  
</td>
                <td><?echo $search_date[$i]?></td>
                <td><?echo $search_name[$i]?></td>
                <td><?echo $search_num[$i]?></td>
                <td><?echo $search_price[$i]?></td>
                <td>

<?
				
   
 if (($summary_month<$tmp_mon)||($order_time<=$nowtime))

	{ echo "超时,不可退订"; }
	else{
	?>	

        <button class="tuidingBtn"
                value="<?echo $search_nid[$i]?>"
                data-value="<?echo $search_product_id[$i]?>"
                data-price="<?echo $search_price[$i]?>"
                data-date="<?echo $search_date[$i]?>">
        退订</button>

<? ;} ?>
          
 
		  </td>
            </tr>
            <? } ?>
            </tbody>
        </table>
    </div>
    </div>



</div>


<?php include 'modules/footer.php'; ?>
</body>
</html>
